package services;

import java.net.DatagramPacket;
import java.util.ArrayList;
import javafx.util.Pair;


public class Packet extends Command {

Command c;
   /*
    * Generowanie pakietu komunikacyjnego z wynikowym typem STRING
    */
    public static String generatePacketAsString(ClientType clientType, MessageType messageType,
            Include include, String data) {

        return clientType + ";" + messageType + ";" + include + ";" + data;
    }

    /*
     * Podzial pakietu na cztery poszczególne elementy
     */
    public static Pair<String,ArrayList<String>> splitPacket(byte[] message, String IP) {
        String packet = new String(message).trim();
    
        ArrayList<String> pieces = new ArrayList<String>();
        pieces.add(packet.split(";")[0]);
        pieces.add(packet.split(";")[1]);
        pieces.add(packet.split(";")[2]);
        pieces.add(packet.split(";")[3]);
        Pair pair = new Pair(IP,pieces);
        return pair;

    }

   
}
